package com.example.signsystem.controller;

import cn.hutool.core.bean.BeanUtil;
import com.example.signsystem.entity.dto.AttendanceDTO;
import com.example.signsystem.entity.dto.QuestionDTO;
import com.example.signsystem.entity.dto.QuestionUnderstandDTO;
import com.example.signsystem.entity.parm.QuestionParam;
import com.example.signsystem.entity.parm.QuestionUnderstandParam;
import com.example.signsystem.entity.po.QuestionPO;
import com.example.signsystem.entity.vo.AttendanceVO;
import com.example.signsystem.entity.vo.QuestionUnderstandVO;
import com.example.signsystem.service.IQuestionService;
import com.qcby.framework.common.pojo.PageParam;
import com.qcby.framework.common.pojo.PageResult;
import com.qcby.framework.common.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sign-system/question")
public class QuestionController {

    @Autowired
    IQuestionService questionService;

    @PostMapping("/question-posting")
    public Result<Boolean> questionPosting(@RequestBody QuestionParam questionParam){
        return Result.getSuccessResult(questionService.questionPosting(questionParam));
    }

    @GetMapping("/question-check")
    public Result<PageResult<QuestionPO>> checkQuestion(PageParam pageParam){
        return Result.getSuccessResult(questionService.checkQuestion(pageParam));
    }

    @GetMapping("/questionAnswer")
    public Result<Boolean> questionAnswer(QuestionUnderstandParam questionUnderstandParam){
        return Result.getSuccessResult(questionService.questionAnswer(questionUnderstandParam));
    }

    @GetMapping("questionUnderstand")
    public Result<QuestionUnderstandVO> questionUnderstand(Long questionId){
        QuestionUnderstandDTO questionUnderstandDTO = questionService.questionUnderstand(questionId);
        QuestionUnderstandVO questionUnderstandVO = BeanUtil.copyProperties(questionUnderstandDTO, QuestionUnderstandVO.class);
        return Result.getSuccessResult(questionUnderstandVO);
    }
}
